package pers.cz.netty;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.io.IOException;

/**
 * @program: PostGirl-panent
 * @description: netty服务端
 * @author: Cheng Zhi
 * @create: 2022-07-01 13:10
 **/
@Component
public class Server {

    Logger logger = LoggerFactory.getLogger(Server.class);

    @Value("${netty.server.port}")
    int port;

    /**
     * netty服务启动类
     * @throws IOException
     */
    @PostConstruct
    public void nettyServerStater() throws IOException {

        // 这里是一个单独的线程工作
        logger.info("启动netty服务.......");
        new Thread(new NettyServerWorker(port)).start();
    }
}
